package com.fly.service.Impl;

import com.fly.bean.UserLog;
import com.fly.bean.Users;
import com.fly.mapper.UserMapper;
import com.fly.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Resource
    UserMapper userMapper;

    /**
     *  根据用户名和密码查询用户信息，可以对其进行进一步的判断
     * @param userName
     * @param userPwd
     * @return
     */
    @Override
    public Users getUserByUserNameAndUserPwd(String userName, String userPwd) {

        return userMapper.getUserByUserNameAndUserPwd(userName,userPwd);
    }

    /**
     * 根据用户Id得到用户信息
     * @param userId
     * @return
     */
    @Override
    public Users getUserById(Integer userId) {

        return userMapper.getUserById(userId);
    }

    /**
     * 修改用户信息
     * @param user
     */
    @Override
    public void modifyUserById(Users user) {
        userMapper.modifyUserById(user);
    }

    /**
     * 添加用户日志信息
     * @param userLog
     * @return
     */
    @Override
    public Integer addUserLog(UserLog userLog) {
        return userMapper.addUserLog(userLog);
    }

    /**
     * 查询原密码是否正确
     * @param userId
     * @param userPwd
     * @return
     */
    @Override
    public Integer selectSrcUserPwdByUserId(Integer userId, String userPwd) {
        return userMapper.selectSrcUserPwdByUserId(userId,userPwd);
    }

    /**
     * 修改密码
     * @param user
     * @return
     */
    @Override
    public Integer modifyPassword(Users user) {
        return userMapper.modifyPassword(user);
    }

    /**
     * 根据用户名查询用户Id
     * @param userName
     * @return
     */
    @Override
    public Integer selectUserIdByUserName(String userName) {
        return userMapper.selectUserIdByUserName(userName);
    }

    /**
     * 根据用户Id查询角色Id
     * @param userId
     * @return
     */
    @Override
    public Integer selectRoleIdByUserId(Integer userId) {
        return userMapper.selectRoleIdByUserId(userId);
    }

    /**
     * 根据用户Id查询userState
     * @param userId
     * @return
     */
    @Override
    public Integer selectUserStateByUserId(Integer userId) {
        return userMapper.selectUserStateByUserId(userId);
    }

    /**
     * 根据角色Id查询roleState
     * @param roleId
     * @return
     */
    @Override
    public Integer selectRoleStateByRoleId(Integer roleId) {
        return userMapper.selectRoleStateByRoleId(roleId);
    }

    /**
     * 根据userState查询sysProValueName
     * @param userState
     * @return
     */
    @Override
    public String selectSysProValueNameByUserState(Integer userState) {
        return userMapper.selectSysProValueNameByUserState(userState);
    }

    /**
     * 根据roleState查询sysProValueName
     * @param roleState
     * @return
     */
    @Override
    public String selectSysProValueNameByRoleState(Integer roleState) {
        return userMapper.selectSysProValueNameByRoleState(roleState);
    }

    /**
     * 查询得到所有的密码进行加密
     * @return
     */
    @Override
    public List<Users> selectAllPassword() {
        return userMapper.selectAllPassword();
    }
}
